package com.kaifamiao.demo.d0727;

public class Person {

    private String name;

    private int age;

    String hobby;

    Person(){}


    private void show(){
        age = 10;
        System.out.println(this.name + ", " + this.age);
    }

    public String getName(){
        return this.name;
    }

    public int getAge(){
        return 20;
    }

    public void setName(String name){
        // 判断字符串相等
        if ("狗蛋".equals(name)){
            this.name = "*子萱";
        } else{
            this.name = name;
        }
    }

    public void setAge(int age){
        if (age > 150 || age < 1){
            System.err.println("你是个妖怪？");
        } else{
            this.age = age;
        }
    }
}
